package com.share.zabbix.response;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.alibaba.fastjson.JSON;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper=false)
public class ZabbixResponseHost extends ZabbixResponseResult {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String ip;
	
    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }

    public String getIp(){        
        String regEx="((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)"; 
        Pattern p = Pattern.compile(regEx); 
        Matcher m = p.matcher(getName());
        while (m.find()) {
            ip = m.group();
        }
		return ip;
    }
}
